<%@ include file="/common/taglibs.jsp"%>
<%@ taglib prefix="system" tagdir="/WEB-INF/tags/system"%>
<probiz:pageHeading pageHeadingKey="orderPickList.heading" />

<content tag="buttons">
   <probiz:iconBtn btnType="print" btnTextKey="orderPickList.button.print" onclick="printPickList();" />
</content>

<search:searchBox formAction="${ctxPath}/order/orderPick.html" enableMoreSearch="true">
	<div class="basic_search">
		<search:basicSearch attrPath="oc.documentNo" attrNameKey="orderPick.documentNo" datatype="String"	operator="LIKE" classes="inputtxt" labelWidth="60px"/>
	</div>
	<div class="more_search">
		<table border="0" cellspacing="0" cellpadding="0" class="search_table">
			<tr>
				<c:set var="createTimeGTE">COL@oc.createTime@Date_Begin@GTE</c:set>
				<c:set var="createTimeLTE">COL@oc.createTime@Date_End@LTE</c:set>
				<th width="60px"><label for="${createTimeGTE}"><fmt:message key="orderPick.createTime"/>:</label></th>
				<td>
					<span><input type="text" id="createTimeGTE" name="${createTimeGTE}" value="${sc==null?requestScope[createTimeGTE]:sc.param[createTimeGTE]}" style="width:70px"  class="input_readonly" readonly  onblur="validateEventHandler();"/></span>
					<probiz:ui_datePicker outPut="createTimeGTE" />
					<fmt:message key ="orderPick.search.to"/>
					<span><input type="text" id="createTimeLTE" name="${createTimeLTE}" value="${sc==null?requestScope[createTimeLTE]:sc.param[createTimeLTE]}" style="width:70px"  class="input_readonly" readonly  onblur="validateEventHandler();"/></span>
					<probiz:ui_datePicker outPut="createTimeLTE" />
				</td>
			</tr>
		</table>
	</div>
</search:searchBox>

<form class="mainForm" name="orderPickListForm" method="post" action="${ctxPath}/order/orderPick.html">
	<!--editURLPath is used in TblDecorator-->
	<div class="top clearfix">
		<ul class="tab">
			<li class="curr"><span><fmt:message key="orderPickList.heading"/></span></li>
		</ul>
		<%@include file="/common/pagingOnlyTop.jsp"%>
	</div>
	<div class="data">		
		<c:set var="checkAll">
			<input type="checkbox" name="allbox" onclick="checkAll(this.form)"	class="checkbox" />
		</c:set>
		<c:set var="isNeedTopPaging" value="true"/>
		
		<table width="100%" border="0" cellspacing="0" cellpadding="0" class="list_table" id="orderPickTable">	
			<tr>
			  	<th width="20"><input onclick="checkAll(this.form)" name="allbox" type="checkbox" value="" /></th>	
				<th style="width:20px;">
					<span class="expand" onclick="toggleScreenAll(this)">&nbsp;</span>
				</th>
				<th style="width:10%" class='sortable ${(sc.param["p-sort"] eq 1)?"sorted order1":((sc.param["p-sort"] eq 2)?"sorted order2":"")}'>		
					<a onclick="sortField(this,1,2)"><fmt:message key="orderPick.documentNo" /></a>
				</th>
				<th style="width:15%" class='sortable ${(sc.param["p-sort"] eq 9)?"sorted order1":((sc.param["p-sort"] eq 10)?"sorted order2":"")}'>
					<a onclick="sortField(this,9,10)"><fmt:message key="orderPick.createTime" /></a>
				</th>
				<th>	
				</th>
			</tr>
			<c:forEach  items="${orderPickList}" var="orderPick" varStatus="status">
				<tr id="tr${orderPick.orderPickId}" class="${(status.index%2==0)?'even':'odd'}">
					<td>
	    				<input type="checkbox" name="multiIds" value="${orderPick.orderPickId}" title="${orderPick.documentNo}" class="checkbox" />
					</td>
					<td>
						 <span class="expand toggleScreen" onclick="toggleScreen(this)">&nbsp;</span>                    
					</td>
					<td>
						${orderPick.documentNo}
					</td>
					<td>
						<common:datetimeFormat date="${orderPick.createTime}" />
					</td>
					<td>
						&nbsp;
					</td>
				</tr>
				<tr style="display: none;" class="${(status.index%2==0)?'even':'odd'}  sub">
					<td></td>
					<td class="consignee" colspan="10">
						<div class="order_show">
							<table cellspacing="0" cellpadding="0" border="0" width="100%">
								<tr>
									<td style="vertical-align:top;width:25%">
										<table cellspacing="0" cellpadding="0" border="0" width="100%" class="consignee_table">
											<tr>
												<th width="100px;"><fmt:message key="orderPick.documentNo" />:</th>
												<td>${orderPick.documentNo}</td>
											</tr>
											<tr>
												<th><fmt:message key="orderPick.createTime" />:</th>
												<td><common:datetimeFormat date="${orderPick.createTime}" /></td>
											</tr>
											
										</table>
									</td>
									<td style="vertical-align:top;width:30%">
										<%---------------------------------购买的商品 -------------------------%>
										<%@include file="include/orderPickList4Product.jspf" %>
										<br/>
										<%---------------------------------兑换的礼品 -------------------------%>
										<%@include file="include/orderPickList4Gift.jspf" %>
									</td>
								</tr>
							</table>
						</div>
					</td>
				</tr>	
			</c:forEach>
			<c:if test="${empty orderPickList}">
				<tr>
					<td colspan="10" style="text-align:center">
						<fmt:message key="list.empty"/>
					</td>
				</tr>
			</c:if>
		</table>	
		<%@include file="/common/pagingOnly.jsp" %>
	</div>
</form>
<script type="text/javascript">
highlightTableRows("orderPickTable");

$j(document).ready(function () {
	__FMTExtend = {
		orderPickList_pleaseSelectOne:"<fmt:message key="orderPickList.pleaseSelectOne"/>"
	};
	$j.extend(__FMT, __FMTExtend); 
	autoApplyValidate(document.forms["orderPickListForm"]);
});	


//对已有结果进行排序,ascValue表示升序时对应的值,descValue表示降序时对应的值
function sortField(linkDOM,ascValue,descValue){
	var jThDOM = $j(linkDOM).parent('th');
	if(jThDOM.hasClass("order1")){
		location.replace('${ctxPath}/order/orderPick.html?p-sort='+descValue);
	}else{
		location.replace('${ctxPath}/order/orderPick.html?p-sort='+ascValue);
	}
}
	

//显示 隐藏全部
function toggleScreenAll(linkDOM){
	if($j(linkDOM).hasClass("expand")){
		$j(linkDOM).removeClass("expand").addClass("shrink");
		$j('span.toggleScreen').each(function(){
			var jTrThis = $j(this).parents('tr:first');
			var jTrFull = jTrThis.next();
			jTrFull.show();
			$j(this).removeClass("expand").addClass("shrink");
		});
	
	}else{
		$j(linkDOM).removeClass("shrink").addClass("expand");
		$j('span.toggleScreen').each(function(){
			var jTrThis = $j(this).parents('tr:first');
			var jTrFull = jTrThis.next();
			jTrFull.hide();
			$j(this).removeClass("shrink").addClass("expand");
		});
	}
}	

//显示 隐藏详细
function toggleScreen(linkDOM){
	var jTrThis = $j(linkDOM).parents('tr:first');
	var jTrFull = jTrThis.next();
	if(jTrFull.is(":hidden")){
		jTrFull.show();
		$j(linkDOM).removeClass("expand").addClass("shrink");
	}else{
		jTrFull.hide();
		$j(linkDOM).removeClass("shrink").addClass("expand");
	}
	
}	
//打印备货单
function printPickList(){
	var paraData=$j(":input[name='multiIds']").serializeArray();
	if(paraData.length>0) {		
		var param = $j.param(paraData);
		var page = __ctxPath+'/order/orderPick.html?doAction=printPickList';
		window.open(page + "&" + param);
	}else{
		alert(__FMT.orderPickList_pleaseSelectOne);	 
	}	
}


</script>